package com.larry.mr.sort;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @ProjectName map-reduce
 * @Author larry
 * @Date 12:10 2022/4/6
 * @Description TODO
 **/
public class FlowBeanMapper extends Mapper<LongWritable, Text,FlowBean,Text> {

    FlowBean k = new FlowBean();
    Text v = new Text();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        String line = value.toString();
        String[] words = line.split("\t");

        //13470253144	180	180	360
        k.setUpFlow(Long.parseLong(words[1]));
        k.setDownFlow(Long.parseLong(words[2]));
        k.setSumFlow(Long.parseLong(words[3]));

        v.set(words[0]);

        context.write(k,v);
    }
}
